import React, { useState, useEffect } from 'react';
import './index.less';
import Teacher from './teacher';
import Footer from './footer';
import Banner from './banner/index';
import { apihook } from '../hooks';

export default function IndexPage() {
  const [img, setImg] = useState([]);
  const initDataFn = async () => {
    let status = 1; // 讲师
    let pageNo = 1; //页数
    let res = await apihook({
      status,
      pageNo,
    });
    let resImg = res.data.data.List;
    const newImg = resImg.map((i) => ({ img: i.img, id: i.id }));
    setImg([...newImg]);
  };
  useEffect(() => {
    initDataFn();
  }, []);

  return (
    <div className="swiper-list">
      <Banner img={img} />
      <Teacher />
      <Footer />
    </div>
  );
}
